﻿using CourseManage.Data;
using CourseManage.Web.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;

namespace CourseManage.Web.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;
        private readonly CourseManageContext _courseManageContext;

        public HomeController(ILogger<HomeController> logger, CourseManageContext courseManageContext)
        {
            _logger = logger;
            _courseManageContext = courseManageContext;
        }

        public IActionResult Index()
        {

            //CourseManage.Data.User user = new Data.User()
            //{
            //    No = "001",
            //    Name = "FranckyTang",
            //    Password = "123456",
            //    Sex = Data.Sex.男,
            //    UserType = Data.UserType.教师
            //};

            //_courseManageContext.Users.Add(user);
            //_courseManageContext.SaveChanges();

            //var user = _courseManageContext.Users.First(o => o.No == "001");

            //_courseManageContext.Users.Remove(user);

            //_courseManageContext.SaveChanges();

            

            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
